import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
import * as schema from './schema';

// Create database connection with explicit configuration for MCP server
export function createMcpDb() {
  const client = createClient({
    url: 'file:./local.db', // Use local SQLite database
    authToken: '', // No auth token needed for local SQLite
  });

  return drizzle(client, { schema });
}

// Export a singleton database instance
export const mcpDb = createMcpDb();